package io.yunho.alg.snowflake.controller;

import io.yunho.alg.snowflake.util.IdSnowFlakeUtil;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author: Jason
 * @date: 2020/12/28 13:19
 * @description:
 */
public class OrderController {
    @Autowired
    private IdSnowFlakeUtil idSnowFlakeUtil;

    public String getIdSnowflake(){
        ExecutorService threadPool = Executors.newFixedThreadPool(5);
        for(int i=0;i<20;i++){
            threadPool.submit(()->{
                System.out.println(idSnowFlakeUtil.snowflakeId());
            });
        }
        threadPool.shutdown();
        return "Hello snowflake";
    }
}
